using UnityEngine;
using QFramework;
using System.Collections.Generic;

namespace ProjectSurviver
{
	public partial class BasketballAbillity : ViewController
	{
		private List<Ball> mBalls = new List<Ball>();

		void Start()
		{
			void CreatBall()
			{
				mBalls.Add(Ball.Instantiate()
					.SyncPosition2DFrom(this)
					.Show());
			}

			void CreatBalls()
			{
				var ballCount2Creat = Global.BasketBallCount.Value + Global.AdditionFlyThingCount.Value - mBalls.Count;
				for (var i = 0; i < ballCount2Creat; i++)
				{
					CreatBall();
				}
			}

			Global.BasketBallCount.Or(Global.AdditionFlyThingCount)
				.Register(CreatBalls)
				.UnRegisterWhenGameObjectDestroyed(gameObject);

			CreatBalls();
		}
	}
}
